@extends('shop::layouts.master')
@section('title')
    订单列表
@endsection
@section('tab')
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-body ">
                        <form class="layui-form layui-col-space5">
                            <div class="layui-input-inline layui-show-xs-block" style="width: 500px;    ">
                                <input type="text" name="ticket_num" placeholder="优惠券券号" value="{{$arr_search['ticket_num']}}" autocomplete="off" class="layui-input">
                            </div>
                            <div class="layui-input-inline layui-show-xs-block">
                                <button class="layui-btn" lay-submit="" lay-filter="sreach">
                                    <i class="layui-icon">&#xe615;</i>
                                </button>
                            </div>
                        </form>
                    </div>
                    <div class="layui-card-body layui_overflow_y ">
                        <table class="layui-table layui-form">
                            <thead>
                            <tr>
                                <th>编号</th>
                                <th>优惠券名称</th>
                                <th>面值金额</th>
                                <th>优惠券号</th>
                                <th>使用说明</th>
                                <th>有效期</th>
                                <th>状态</th>
                                <th>操作</th></tr>
                            </thead>
                            <tbody>
                            @if( !empty($data))
                                @foreach($data as $key=>$value)
                                    <tr>
                                        <td>{{ $value['id'] }}</td>
                                        <td>{{ $value['get_coupon_info']['name'] }}</td>
                                        <td>{{ round( $value['get_coupon_info']['price_all'] , 2 ) }}</td>
                                        <td>{{ $value['ticket_num'] }}</td>
                                        <td>{{ $value['get_coupon_info']['content'] }}</td>
                                        <td>{{ $value['over_at'] }}</td>
                                        <td>{{ $value['status_msg'] }}</td>
                                        <td>
                                            <a title="使用优惠券" data-href="{{route('shop_coupon_use',['id'=>$value['id']])}}" data-title="确定使用此券吗吗？请谨慎操作" href="javascript:;" class="layui-btn layui-btn-danger ajax_member_del">
                                                使用此券</a>
                                        </td>
                                    </tr>
                                @endforeach
                            @else
                                <td colspan="66" align="center">暂无数据</td>
                            @endif
                            </tbody>
                        </table>
                    </div>
                    {{--横眉冷对千夫指 --}}
                    <div class="layui-card-body ">
                        <div class="page">
                            {{$page_link}}
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

@endsection


@section('tab_js')
    <script>
        layui.use(['form', 'layer', 'jquery'], function () {
            $ = layui.jquery;
            var form = layui.form,
                layer = layui.layer;

            form.on('switch(switchTest)', function(data){
                var id = $(this).attr('data-id');
                var status = 1;
                if( $(this).attr('data-status') == 1 ){
                    status = 2;
                }
                $.ajax({
                    url: js_url('shop-coupon-update'),
                    type: 'post',
                    data: {id:id,status:status,'_token': '{{csrf_token()}}','act':'status'},
                    dataType: "json",
                    success: function (result) {
                        if (result.state === 0) {
                            layer.msg(result.msg, {time: 500, icon: 6}, function () {
                                //关闭当前frame
                                // xadmin.close();
                                // 可以对父窗口进行刷新
                                // xadmin.father_reload();
                            });
                        }else if( result.state === 2 ){
                            layer.msg(result.msg, {time: 1000, icon: 5}, function () {
                                location.reload();
                            });
                        } else {
                            layer.msg(result.msg, {time: 2000, icon: 5});
                        }
                    }
                });
            });

        })
    </script>
@endsection




